package com.yk.faceapplication.view;


import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

public class PagerScrollView extends ScrollView {
	private float xDistance, yDistance, xLast, yLast;
//	private ScrollViewListener scrollViewListener = null;

	public PagerScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
		setVerticalScrollBarEnabled(false);
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			xDistance = yDistance = 0f;
			xLast = ev.getX();
			yLast = ev.getY();
			break;
		case MotionEvent.ACTION_MOVE:
			final float curX = ev.getX();
			final float curY = ev.getY();

			xDistance += Math.abs(curX - xLast);
			yDistance += Math.abs(curY - yLast);
			xLast = curX;
			yLast = curY;

			if (xDistance > yDistance) {
				return false;
			}
		}

		return super.onInterceptTouchEvent(ev);
	}

//	public void setScrollViewListener(ScrollViewListener scrollViewListener) {
//		this.scrollViewListener = scrollViewListener;
//	}
//
//	@Override
//	protected void onScrollChanged(int x, int y, int oldx, int oldy) {
//		super.onScrollChanged(x, y, oldx, oldy);
//		if (scrollViewListener != null) {
//			scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
//		}
//	}
//
//	// �������ܵĸ߶�
//	public int getTotalVerticalScrollRange() {
//		return computeVerticalScrollRange();
//	}
	
	
	@Override
	 protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
	  return 0;
	 } 

}
